home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / transpor / ifmail23.z / ifmail23 / ifmail / ifcico / ifroute.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-09  |  1.4 KB  |  84 lines

  1. #include <sys/types.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #ifdef HAS_SYSLOG
  7. #include <syslog.h>
  8. #endif
  9. #include <sysexits.h>
  10. #include "getopt.h"
  11. #include "lutil.h"
  12. #include "xutil.h"
  13. #include "ftn.h"
  14. #include "nodelist.h"
  15. #include "config.h"
  16. #include "version.h"
  17.  
  18. void usage(void)
  19. {
  20.     confusage("<node>");
  21.     fprintf(stderr,"  <node>    in domain form, e.g. f11.n22.z3\n");
  22. }
  23.  
  24. faddr *bestroute(faddr*,faddr*,node*);
  25.  
  26. int main(argc,argv)
  27. int argc;
  28. char *argv[];
  29. {
  30.     int c,rc;
  31.     faddr *adr=NULL,*raddr=NULL;
  32.     faddr *bestaka;
  33.     node *nlent;
  34.  
  35. #ifdef MAILLOG
  36.         logfacility=MAILLOG;
  37. #endif
  38.  
  39.     setmyname(argv[0]);
  40.     while ((c=getopt(argc,argv,"x:r:n:l:a:I:h")) != -1)
  41.     if (confopt(c,optarg)) switch (c)
  42.     {
  43.         default:    usage(); exit(EX_USAGE);
  44.     }
  45.  
  46.     if (readconfig())
  47.     {
  48.         fprintf(stderr,"Error getting configuration, aborting\n");
  49.         exit(EX_DATAERR);
  50.     }
  51.  
  52.     if (argv[optind] == NULL)
  53.     {
  54.         usage();
  55.         rc=EX_USAGE;
  56.     }
  57.     else if ((adr=parsefaddr(argv[optind])) == NULL)
  58.     {
  59.         logerr("unrecognizable address \"%s\"",argv[optind]);
  60.         rc=EX_USAGE;
  61.     }
  62.     else
  63.     {
  64.         bestaka=bestaka_s(adr);
  65.         nlent=getnlent(adr);
  66.         if (nlent->pflag != DUMMY)
  67.         {
  68.             raddr=bestroute(adr,bestaka,nlent);
  69.             printf("%s\n",ascinode(raddr,0x3f));
  70.             rc=0;
  71.         }
  72.         else rc=EX_NOHOST;
  73.     }
  74.  
  75.     return rc;
  76. }
  77.  
  78. faddr *bestroute(remote,local,nlent)
  79. faddr *remote,*local;
  80. node *nlent;
  81. {
  82.     return remote;
  83. }
  84.